//
//  DCFlowControl.h
//  DCA
//
//  Created by James Critchley on 8/15/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#ifndef _DCFLOWCONTROL_H_
#define _DCFLOWCONTROL_H_

#include "DCAComputation.h"
#include "syncobject.h"

class DCFlowControl{
public:
    DCAComputation *computation;
    NullSync null_sync;

    DCFlowControl();
    virtual ~DCFlowControl();
    
    virtual void kinAssembly_traversal()=0;
    virtual void kinSolve_traversal()=0;
    virtual void null_traversal()=0;
    virtual void assembly_traversal() = 0;
    virtual void solve_traversal() = 0;
};

class DCBinarySequentialFlow: public DCFlowControl{
public:
    DCFlowControl *child1;
    DCFlowControl *child2;
    
    SyncObject *parent_sync;

    DCBinarySequentialFlow();
    virtual ~DCBinarySequentialFlow();
    
    virtual void kinAssembly_traversal(){}
    virtual void kinSolve_traversal(){}
    virtual void null_traversal(){}
    virtual void assembly_traversal();
    virtual void solve_traversal();
};

class DCPolySequentialFlow : public DCFlowControl{
    //handles "N" children.
};

class DCBinaryParallelFlow : public DCFlowControl{
public:
    DCFlowControl *child1;
    DCFlowControl *child2;
    
    SyncObject *parent_sync;
    SyncObject *child_sync;

    DCBinaryParallelFlow();    
    ~DCBinaryParallelFlow();
    
    virtual void kinSolve_traversal();
    virtual void kinAssembly_traversal();
    virtual void null_traversal();
    virtual void assembly_traversal();
    virtual void solve_traversal();
};

class DCPolyParallelFlow : public DCFlowControl{
};

class DCFlowTerminator : public DCFlowControl
{
    // has no children
public:
    SyncObject *parent_sync;
    
    DCFlowTerminator();
    ~DCFlowTerminator();
    
    virtual void kinAssembly_traversal();
    virtual void kinSolve_traversal();
    virtual void null_traversal();
    virtual void assembly_traversal();
    virtual void solve_traversal();
};

#endif